#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
typedef struct TNode
{
    char Data;
    struct TNode *lchild;
    struct TNode *rchild;
}*PTree,Tree;
void PreorderTraverse(PTree T);
void CreateTree(PTree *T,char *s1,char *s2,int len);
int main()
{
    //freopen("in.txt","r",stdin);
    char s1[10];
    char s2[10];
    cin >> s1 >> s2;
    int len = strlen(s2);
    PTree T;
    CreateTree(&T,s1,s2,len);
    PreorderTraverse(T);
}

void CreateTree(PTree *T,char *s1,char *s2,int len)
{
    if(len <= 0) return;
    else
    {
        char *temp = s1;
        while (*temp != s2[len-1])
        {
            temp++;
        }
        int k = temp - s1;
        *T = (PTree) malloc(sizeof(TNode));
        (*T)->Data = *temp;
        CreateTree(&((*T)->lchild),s1,s2,k);
        CreateTree(&((*T)->rchild),temp+1,s2+k,len-k-1);
    }
}

void PreorderTraverse(PTree T)
{
    if(T!=NULL)
    {
        printf("%c",T->Data);
        PreorderTraverse(T->lchild);
        PreorderTraverse(T->rchild);
    }
}